package o;

import android.annotation.TargetApi;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.os.Build.VERSION;
import android.os.Looper;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Queue;

public final class aau {
    private static final char[] ˏ = "0123456789abcdef".toCharArray();
    private static final char[] ॱ = new char[64];

    static /* synthetic */ class AnonymousClass5 {
        static final /* synthetic */ int[] ˊ = new int[Config.values().length];

        static {
            try {
                ˊ[Config.ALPHA_8.ordinal()] = 1;
            } catch (NoSuchFieldError e) {
            }
            try {
                ˊ[Config.RGB_565.ordinal()] = 2;
            } catch (NoSuchFieldError e2) {
            }
            try {
                ˊ[Config.ARGB_4444.ordinal()] = 3;
            } catch (NoSuchFieldError e3) {
            }
            try {
                ˊ[Config.RGBA_F16.ordinal()] = 4;
            } catch (NoSuchFieldError e4) {
            }
            try {
                ˊ[Config.ARGB_8888.ordinal()] = 5;
            } catch (NoSuchFieldError e5) {
            }
        }
    }

    @NonNull
    public static String ˏ(@NonNull byte[] bArr) {
        String ˏ;
        synchronized (ॱ) {
            ˏ = ˏ(bArr, ॱ);
        }
        return ˏ;
    }

    @NonNull
    private static String ˏ(@NonNull byte[] bArr, @NonNull char[] cArr) {
        for (int i = 0; i < bArr.length; i++) {
            int i2 = bArr[i] & 255;
            cArr[i * 2] = ˏ[i2 >>> 4];
            cArr[(i * 2) + 1] = ˏ[i2 & 15];
        }
        return new String(cArr);
    }

    @TargetApi(19)
    public static int ˏ(@NonNull Bitmap bitmap) {
        if (bitmap.isRecycled()) {
            throw new IllegalStateException("Cannot obtain size for recycled Bitmap: " + bitmap + "[" + bitmap.getWidth() + "x" + bitmap.getHeight() + "] " + bitmap.getConfig());
        }
        if (VERSION.SDK_INT >= 19) {
            try {
                return bitmap.getAllocationByteCount();
            } catch (NullPointerException e) {
            }
        }
        return bitmap.getHeight() * bitmap.getRowBytes();
    }

    public static int ॱ(int i, int i2, @Nullable Config config) {
        return (i * i2) * ˋ(config);
    }

    private static int ˋ(@Nullable Config config) {
        if (config == null) {
            config = Config.ARGB_8888;
        }
        switch (AnonymousClass5.ˊ[config.ordinal()]) {
            case 1:
                return 1;
            case 2:
            case 3:
                return 2;
            case 4:
                return 8;
            default:
                return 4;
        }
    }

    public static boolean ˊ(int i, int i2) {
        return ˎ(i) && ˎ(i2);
    }

    private static boolean ˎ(int i) {
        return i > 0 || i == Integer.MIN_VALUE;
    }

    public static void ॱ() {
        if (!ˎ()) {
            throw new IllegalArgumentException("You must call this method on the main thread");
        }
    }

    public static void ˊ() {
        if (!ˋ()) {
            throw new IllegalArgumentException("You must call this method on a background thread");
        }
    }

    public static boolean ˎ() {
        return Looper.myLooper() == Looper.getMainLooper();
    }

    public static boolean ˋ() {
        return !ˎ();
    }

    @NonNull
    public static <T> Queue<T> ॱ(int i) {
        return new ArrayDeque(i);
    }

    @NonNull
    public static <T> List<T> ˏ(@NonNull Collection<T> collection) {
        List<T> arrayList = new ArrayList(collection.size());
        for (Object next : collection) {
            if (next != null) {
                arrayList.add(next);
            }
        }
        return arrayList;
    }

    public static boolean ॱ(@Nullable Object obj, @Nullable Object obj2) {
        if (obj == null) {
            return obj2 == null;
        } else {
            return obj.equals(obj2);
        }
    }

    public static boolean ˎ(@Nullable Object obj, @Nullable Object obj2) {
        if (obj == null) {
            return obj2 == null;
        } else {
            if (obj instanceof vi) {
                return ((vi) obj).ॱ(obj2);
            }
            return obj.equals(obj2);
        }
    }

    public static int ˊ(int i) {
        return ˏ(i, 17);
    }

    public static int ˏ(int i, int i2) {
        return (i2 * 31) + i;
    }

    public static int ˊ(float f) {
        return ˋ(f, 17);
    }

    public static int ˋ(float f, int i) {
        return ˏ(Float.floatToIntBits(f), i);
    }

    public static int ˊ(@Nullable Object obj, int i) {
        return ˏ(obj == null ? 0 : obj.hashCode(), i);
    }

    public static int ˋ(boolean z, int i) {
        return ˏ(z ? 1 : 0, i);
    }
}
